package main

import (
	"fmt"
	"gitee.com/ichub/goconfig/common/base/encrypt"
	"gitee.com/ichub/goconfig/common/ichublog"
	"github.com/sirupsen/logrus"
	"github.com/spf13/cobra"
)

func main() {
	ichublog.InitLogrus()
	var rootCmd = &cobra.Command{
		Use:   "enc xxx/dec xxx",
		Short: "enc pwd ,dec passwd ",
		Long:  "enc pwd ,dec pwd",
		Run: func(cmd *cobra.Command, args []string) {
			if len(args) < 2 {
				//logrus.Error("args must > 2")
				logrus.Info(cmd.Usage())
				return
			}
			fmt.Println("enc ", args)
			if args[0] == "enc" {
				var ret = encrypt.EncDecInst.EncBase64(args[1])
				fmt.Println(ret)
			} else {
				var ret = encrypt.EncDecInst.DecBase64(args[1])
				fmt.Println(ret)
			}
		},
	}

	if err := rootCmd.Execute(); err != nil {
		logrus.Error(err)
	}
}
